package com.glc.gao.gavin.rxjavademo.operator;

import android.util.Log;
import android.view.View;

import com.glc.gao.gavin.rxjavademo.R;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

public class BufferActivity extends BaseActivity {
    @Override
    public int getDescribeText() {
        return R.string.describe_buffer;
    }

    @Override
    protected int getContextView() {
        return R.layout.activity_buffer;
    }

    public void executeBuffer(View view) {


        Observable.just(1, 2, 3, 4, 5, 6, 7, 8)
                .buffer(2, 3)
                .subscribe(new Consumer<List<Integer>>() {
                    @Override
                    public void accept(@NonNull List<Integer> integers) throws Exception {
                        print("____start_____");
                        print("buffer size : " + integers.size() + "\n");
                        print("buffer value : ");
                        for (Integer i : integers) {
                            print(i + "");
                        }
                        print("____end_____");
                    }
                });

    }
}
